Skip to content

Keep --status read-only by not restoring preferences for it - #35

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/status-read-only-16
Oct 7, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/status-read-only-16

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #16

What changed

  • TrayAppBuilder.RunAsync now restores preferences only when useTray && !options.ShowStatus.
    • Before this, a --status run on a machine with a desktop session called every persisted toggle's setter.
    • It then returned without going through OnStop, so anything a setter acquired (a sleep inhibitor, for example) was never released.
    • The report also showed the remembered state, not the state the machine was actually in.
  • App option handlers still apply before the status report, as before.
  • CLAUDE.md's description of the run order now notes that --status skips the restore.

Tests

  • RunAsync_WithStatusAndARememberedToggle_RunsNoSetterAndReportsTheLiveState:
    • Seeds awake = true and runs --tray --status.
    • Asserts that the exit code is 0, that the setter was never called, and that the status getter saw the live value (false).
    • It fails on main with setterCalls == 1; I checked this by reverting the condition.
  • Full suite: 126 passed, 1 skipped (the same test that was skipped before), 0 failed. The solution build is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SwBwi3NknT7dGVuSEED1DX


Generated by Claude Code

RunAsync restored persisted toggles, running each setter, before handling
--status, and then returned without calling OnStop. A plain status query
on a desktop session could take a resource such as a sleep inhibitor and
never release it, and it reported the remembered state rather than the
live one. Preferences are now restored only when the run is not --status.

Fixes #16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SwBwi3NknT7dGVuSEED1DX
@sonarqubecloud

sonarqubecloud Bot commented Oct 7, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit d5487fc into main Oct 7, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--status runs toggle setters from remembered preferences and never calls OnStop, so a status query takes the tool's resource and doesn't release it

2 participants